/*
* Powered By [choudou5]
* Web Site: http://www.hsolr.com
* License：MIT
* Since 2018 - 2020
*/
package com.choudou5.solr.service.biz;

import com.choudou5.solr.annotation.ServiceInfo;
import com.choudou5.solr.bean.biz.BizDataBean;
import com.choudou5.solr.service.BaseService;

import java.util.Date;

/**
 * @name 业务数据 Service
 * @author choudou5
 * @date：2018-08-14
 */
@ServiceInfo(table = "solr_biz_data", desc = "业务数据")
public class BizDataService extends BaseService<BizDataBean> {

    public BizDataBean getByBizKey(String bizKey) {
        BizDataBean bean = findOne("biz_key = '" + bizKey + "'");
        return bean;
    }

    public void updateBizData(String bizKey, String title, String bizContent) {
        BizDataBean bean = getByBizKey(bizKey);
        if(bean != null){
            bean.setUpdateTime(new Date());
            bean.setJsonContent(bizContent);
            update(bean);
        }else{
            bean = new BizDataBean(bizKey, title, bizContent);
            add(bean);
        }
    }

}